﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EyFramework.ORM;
using Ncov2019.Entity;

namespace Ncov2019.Core.Dao
{
    /// <summary>
    ///  ZJ_JIUZHENXX表的数据库操作 
    /// </summary>
    public class ZjJiuzhenxxDao : BaseDaoHis<ZjJiuzhenxx>, IZjJiuzhenxxDao
    {
        public List<ZjJiuzhenxx> QueryByShouzhenjl(string start, string end)
        {
            string sql = @"select m.* from (select distinct bingrenid,xingming,xingbie,nianling||nianlingdw as old,jiatingdz,jiatingdh,bingrenqx,(select keshimc from his6.gy_keshi where keshiid=a.jiuzhenks) keshimc,(select zhigongxm from his6.gy_zhigongxx where zhigongid=a.jiuzhenys) zhigongxm
                            ,decode((select count(*) from HIS6.zj_jiuzhenxx where bingrenid=a.bingrenid and jiuzhenrq between (TO_DATE ('" + start + "'||' 00:00:00', 'YYYY-MM-DD HH24:MI:SS')-7) AND (TO_DATE ('" + end + "'||' 23:59:59', 'YYYY-MM-DD HH24:MI:SS')-1) and jiuzhenks in('111201', '111202')),0,'首诊','复诊') szbz from HIS6.zj_jiuzhenxx a where a.jiuzhenks IN ('111201', '111202') and a.jiuzhenzt <> 0 and a.jiuzhenrq BETWEEN TO_DATE ('" + start + "'||' 00:00:00', 'YYYY-MM-DD HH24:MI:SS')AND TO_DATE ('" + end + "'||' 23:59:59', 'YYYY-MM-DD HH24:MI:SS')) m where SZBZ='首诊'";
            return Db.Ado.SqlQuery<ZjJiuzhenxx>(sql);
        }
    }
}
